﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Text.RegularExpressions;

using Javavaj.iHunter.UI;

namespace Javavaj.iHunter.UI
{
    static internal class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static internal void Main()
        {

#if !DEBUG
            try
#endif
            {
                 
                Application.EnableVisualStyles();
                // Application.SetCompatibleTextRenderingDefault(false);
                // Enabling Windows XP visual effects before any controls are created

                System.Globalization.CultureInfo DefaultCulture = System.Globalization.CultureInfo.CurrentUICulture;

                // 显示启动画面
                Splash splashWindow = new Splash();
                splashWindow.Show();
                Application.DoEvents();
                Javavaj.iHunter.Core.ClientCore clientCore = new Javavaj.iHunter.Core.ClientCore();
                clientCore.Initialize();

                System.Xml.XmlDocument settings = clientCore.GetGlobalSettings();
                string lang = settings.DocumentElement["Language"].InnerText;
                System.Globalization.CultureInfo info = null;
                if (lang.Length == 0)
                    info = DefaultCulture;
                else
                    info = new System.Globalization.CultureInfo(lang);

                System.Threading.Thread.CurrentThread.CurrentUICulture = info;
                
                //创建主窗口
                splashWindow.StatusText = "Creating user interface...";
                MainForm mainWindow = new MainForm(clientCore);       
                //初始化完毕
                splashWindow.Dispose();
               
                // Create the main window and run it
                Application.Run(mainWindow);


            }
#if !DEBUG
            catch (Exception e)
            {
                ErrorReportForm.Show(null, e);
            }
            finally
            {
                
            }
#endif
            return;

        }
    }
}